#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""

Auxiliary functions to sed.py

Created on Fri Jan 23 11:15:45 2015

@author: azzollini
"""

from __future__ import absolute_import, unicode_literals, division, print_function


import numpy as np

def BB(wavel,Temp):
    """Planck Function.
    Gives the blackbody flux (i.e. PI*Intensity) ergs/cm2/s/a
    
    Temp: Kelvin
    wavel: microns
    
    after planck.pro
    
    """

    w = wavel / 1.E4 # microns to cm
    c1 = 3.7417749E-5 # =2*np.pi*h*c*c
    c2 = 1.4387687 # =h*c/k
    val = c2/w/Temp
    bb = c1 / (w**5. * (np.exp(val)-1.))
    return bb * 1.E-8 # ergs / cm2 / s / A
    
    
def logresample(flambda,wavel):
    """ """
    return flambda * 0.
    
if __name__ == '__main__':
    """Testing the sed module."""
    
    print('Emission from Black Body at 100K, at 10 um : %.8f ergs / cm2 / s / A' % \
        BB(10.,100.))
    print('IDL result (planck.pro): 0.00021147')
    
    